package hello;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Vector;

@Configuration
@ConfigurationProperties(prefix="ttranslate")
public class TtranslateProperties {

    private int currentIndex = 0;

    private final List<Map<String, String>> ticketpool = new Vector<>();

    public List<Map<String, String>> getTicketpool() {
        return ticketpool;
    }

    public synchronized Map<String, String> getNextTicket() throws Exception {
        if (currentIndex >= ticketpool.size())
            currentIndex = 0;
        return ticketpool.get(currentIndex++);
    }
}